{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "vscode": {
     "languageId": "plaintext"
    }
   },
   "outputs": [],
   "source": [
    "import random\n",
    "\n",
    "# 创建一个包含10个随机整数的列表，数值范围在1到100之间\n",
    "numbers = [random.randint(1, 100) for _ in range(10)]\n",
    "\n",
    "print(\"排序前的数字列表:\")\n",
    "print(numbers)\n",
    "\n",
    "# 方法1：使用列表的sort()方法进行排序（该方法会修改原列表）\n",
    "numbers.sort()\n",
    "\n",
    "# 如果你希望保留原列表不变，可以创建一个新列表并进行排序（例如，使用sorted()函数）\n",
    "# sorted_numbers = sorted(numbers)\n",
    "# 但在这个例子中，我们使用了sort()方法，因此sorted_numbers这一步是注释掉的\n",
    "\n",
    "print(\"\\n排序后的数字列表:\")\n",
    "print(numbers)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
